package com.clf.springBoot.modules.test.dao;


import com.clf.springBoot.modules.test.entity.Country;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface CountryDao {

    @Select("select * from test_country where country_id=#{countryId}")
    @Results(id = "countryResults" ,value = {
            @Result(property = "countryId",column = "country_id"),
            @Result(property = "cities",
                    column = "country_id",
                    javaType= List.class,
                    many = @Many(select = "com.clf.springBoot.modules.test.dao.CityDao.getCitiesByCountryId")
            )
    })
    Country getCountryByCountryId(int countryId);


    @Select("select * from test_country where country_name=#{countryName}")
    @ResultMap(value = "countryResults")
    Country getCountryByCountryName(String countryName);
}
